//
//  GPSDataManager.m
//  Lightthings
//
//  Created by 王岩 on 2025/1/3.
//

#import "GPSDataManager.h"

@interface GPSDataManager ()
/* <#note#> */
@property (nonatomic, strong) NSMutableArray * gpsList;
@end

@implementation GPSDataManager
SingletonM;


- (void)addNewGPSData:(NSString *)data {
    DDLogDebug(@"记录GPS数据:%@",data);
    [self.gpsList addObject:data];
}

- (NSArray *)getAllGPSData {
    
    NSMutableArray * list = [[NSMutableArray alloc] init];
    //  处理 GPS数据
    for ( int i = 0 ; i < self.gpsList.count; i ++) {
        //  00000000 0a 00 06c562dc 0155892e
        NSString * valueStr = [self.gpsList[i] substringWithRange:NSMakeRange(12, 2)];
        unsigned long value = strtoll([[NSString stringWithFormat:@"0x%@",valueStr] UTF8String], 0, 16);
        if ((value & 0x80) == 0x80) {
            value = value & 0x7f;
        }

        valueStr = [self.gpsList[i] substringWithRange:NSMakeRange(12, 8)];
        value = strtoll([[NSString stringWithFormat:@"0x%@",valueStr] UTF8String], 0, 16);
        NSLog(@"精度：%lu",value);
        valueStr = [self.gpsList[i] substringWithRange:NSMakeRange(20, 8)];
        value = strtoll([[NSString stringWithFormat:@"0x%@",valueStr] UTF8String], 0, 16);
        NSLog(@"纬度：%lu",value);
        
    }
    return self.gpsList;
    return list;
}


- (NSMutableArray *)gpsList {
    if (!_gpsList) {
        _gpsList =[[NSMutableArray alloc] init];
    }
    return _gpsList;
}

@end
